<?
require_once  '../classes/DisciplinaManager.php';
require_once  '../classes/DisciplinaDataManager.php';
require_once  '../classes/ConnectionDB.php';
require_once '../bean/Disciplina.php';

$db =ConnectionDB::getInstance()->connectToDB();

$disciplineUtente = DisciplinaDataManager::getInstance()->getDisciplineUtente($db);

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Nuovo Test - step 1 - </title>
        <script src="../glassboxLatest/glassbox.2.0.0/javascripts/prototype.js" type="text/javascript"></script>
        <script src="../glassboxLatest/glassbox.2.0.0/javascripts/scriptaculous/effects.js" type="text/javascript"></script>
        <script src="../glassboxLatest/glassbox.2.0.0/javascripts/glassbox/glassbox.js" type="text/javascript"></script>
        <style type="text/css">
            @import url("../css/style.css");

            #testForm {
                padding-top: 3%;
                margin-left: -5px;
            }

            #testFormCont
            {
                padding-left: 2%;
                padding-top: 3%;
            }

            #testFormCont table
            {

            }


        </style>
        <script type="text/javascript">
            path_to_root_dir = "../glassboxLatest/glassbox.2.0.0/";
            var listaDomande;
            var numItem=10;
            var currentIndex=0;

            window.onload = function()
            {
                var testForm = new GlassBox();
                testForm.init( 'testForm', '840px', '390px', 'hidden','',true, false);
                testForm.ipos();
                testForm.appear();
            }

            function checkForm()
            {
                var nomeTest = document.getElementById('nomeTest').value;
                var oreTest = document.getElementById('oreTest').value;
                var minutiTest = document.getElementById('minutiTest').value;

                var strErr="";

                if(nomeTest.length==0)
                    strErr+="16*";
                
                if(oreTest.length==0)
                    strErr+="17*";
                if(parseInt(oreTest)<0)
                    strErr+="18*";
                if(minutiTest.length==0)
                    strErr+="19*";
                if(parseInt(minutiTest)<0 || parseInt(minutiTest) >60)
                    strErr+="20*";

                if(strErr.length>0)
                {
                    location.href='../portal/manageErrors.php?lista='+strErr;
                    return false;
                }
                return true;
            }

        </script>
    </head>
    <body>
        <?php include '../portal/header.php';?>
        <center>
            <div id="testForm">
                <div id="testFormCont">
                    <form method="POST" action="newTest_2.php" onsubmit="return checkForm();">
                        <table cellpadding="3" style="display: block; padding-left: 70%">
                            <tr>
                                <td colspan="2">&nbsp;</td>
                                <td style="color: #3e7ad4;"><strong>Step 1 - Dettaglio test</strong></td>
                            </tr>
                            <tr>
                                <td colspan="2">&nbsp;</td>
                                <td style="color: gray;">Step 2 - Scelta domande</td>
                            </tr>
                            <tr>
                                <td colspan="2">&nbsp;</td>
                                <td style="color: gray">Step 3 - Conferma test</td>
                            </tr>
                        </table>
                        <table cellpadding="6" style="display: inline; padding-top: 2%;">
                            <tr>
                                <th>Nome test : </th>
                                <td><input type="text" name="nome" id="nomeTest" /></td>
                            </tr>
                            <tr>
                                <th>Tempo richiesto : </th>
                                <td>
                                    <table>
                                        <tr>
                                            <td><input type="text" name="ore" id="oreTest" size="2"/> hh : <input type="text" name="minuti" id="minutiTest"size="2"/> mm</td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <th>Disciplina: </th>
                                <td>
                                    <select name="codiceDisciplina">
                                        <?
                                        for($i=0;$i<count($disciplineUtente); $i++)
                                        {

                                            $disciplinaDesc = DisciplinaDataManager::getInstance()->getDisciplina($db, $disciplineUtente[$i]);
                                           
                                                $str = trim($disciplinaDesc->getNome()); ?>
                                                <option value="<?= $disciplinaDesc->getCodice()?>"><?= $str ?></option>
                                           <?
                                        }?>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2"></td>
                                <td><input type="submit" value="Continua" /></td>
                            </tr>
                        </table>
                    </form>
                </div>
            </div>
        </center>
    </body>
</html>
